{% extends "layout.html" %}
{% block title %}账户余额{% endblock %}
{% block content %}
    <div>
        <div class="row justify-content-center">
            <div class="col-12 col-md-10 col-lg-8">
                <div class="card-body row no-gutters align-items-center">
                    <div class="col-auto">
                        <i class="fas fa-search h4 text-body"></i>
                    </div>
                    <div class="col">
                        <input class="form-control form-control-lg form-control-borderless" type="search" id="account" placeholder="账户地址">
                    </div>
                    <div class="col-auto">
                        <button class="btn btn-lg btn-success" id="get_balance">查询余额</button>
                    </div>
                </div>
            </div>
        </div>
        <div>
            <h5 id="balance"></h5>
        </div>
    </div>

{% endblock %}
{% block script %}
    <script>
        // 加载区块数据
        $("#get_balance").click(function(){
            var account = $("#account").val();
            if(!account) {
                alert("请输入账户地址");
            }
            $.post("/balance",{
              account: account
            },
            function (data) {
              $('#balance').html("余额：" + data.balance + " 以太币");
            });

        })
    </script>
{% endblock %}
